﻿namespace Cubezicles.UI
{
    using System.Collections.Generic;
    using Microsoft.Xna.Framework;
    using Microsoft.Xna.Framework.Graphics;

    public class HelpPane : ManagerPane
    {
        string[] instr = {"Instructions1", "Instructions2", "Instructions3"};

        public HelpPane(Game1 game) : base(game)
        {
            int xPos = 50;
            int yPos = 50;
            int w = game.screenW - xPos*2;
            int h = 450;

            PanePosition = new Vector2(xPos, yPos);
            PaneSize = new Vector2(w, h);
            FrameTitle = game.Messages["HelpPaneTitle"];
        }

        protected override void LoadContent()
        {
            butts = Game.Content.Load<Texture2D>("UI/buttons");

            base.LoadContent();
        }

        public override void Draw(GameTime gameTime)
        {
            if (IsVisible)
            {
                // Create a list of UI controls
                controls = new List<Button>();

                // Get the screen width and height
                int screenH = GraphicsDevice.Viewport.Height;
                int screenW = GraphicsDevice.Viewport.Width;

                game.SpriteBatch.Begin();

                // Draw the frame that hold the info
                DrawFrame();

                float currY = 100.0f;
                //Draw the instructions
                foreach (string writeme in instr)
                {
                    game.SpriteBatch.DrawString(game.Fonts["needs"], game.Messages[writeme], new Vector2(80, currY), game.UIblue);
                    currY += game.Fonts["needs"].MeasureString(game.Messages[writeme]).Y;
                }

                // Draw the okay button
                int xpos = (screenW / 2)- 40;
                int ypos = screenH - 150;
                DrawOKbutton(xpos, ypos); // in base class

                // Draw ALL the buttons
                controls.ForEach(control => control.Update(GraphicsDevice.Viewport, game.ms, game.oldms));
                controls.ForEach(control => control.Draw(game.SpriteBatch, GraphicsDevice.Viewport));

                game.SpriteBatch.End();
            }
        }
    }
}